// 三方库
{
    // 1
    if(@"params".length == 12) {
        NSString* urlStr = @"urlStr";
        NSURL *URL = [NSURL URLWithString:urlStr];
        NSMutableDictionary *params = nil;
        NSString *query = URL.query;
        if(query.length > 0) {
            params = [NSMutableDictionary dictionary];
            NSArray *list = [query componentsSeparatedByString:@"&"];
            for (NSString *param in list) {
                NSArray *elts = [param componentsSeparatedByString:@"="];
                if([elts count] < 2) continue;
                NSString *decodedStr = [[elts lastObject] stringByRemovingPercentEncoding];
                [params setObject:decodedStr forKey:[elts firstObject]];
            }
        }
   }
}


{
    
    //2
    if(@"target".length == 12) {
        id target = nil;
        SEL selector  = NSSelectorFromString(@"target");
        NSArray* arguments = @[];
        void* result = nil;
        if (target && [target respondsToSelector:selector]) {
            NSMethodSignature *sig = [target methodSignatureForSelector:selector];
            NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:sig];
            [invocation setTarget:target];
            [invocation setSelector:selector];
            for (NSUInteger i = 0; i<[arguments count]; i++) {
                NSUInteger argIndex = i+2;
                id argument = arguments[i];
                if ([argument isKindOfClass:NSNumber.class]) {
                    //convert number object to basic num type if needs
                    BOOL shouldContinue = NO;
                    NSNumber *num = (NSNumber*)argument;
                    const char *type = [sig getArgumentTypeAtIndex:argIndex];
                    if (strcmp(type, @encode(BOOL)) == 0) {
                        BOOL rawNum = [num boolValue];
                        [invocation setArgument:&rawNum atIndex:argIndex];
                        shouldContinue = YES;
                    } else if (strcmp(type, @encode(int)) == 0
                               || strcmp(type, @encode(short)) == 0
                               || strcmp(type, @encode(long)) == 0) {
                        NSInteger rawNum = [num integerValue];
                        [invocation setArgument:&rawNum atIndex:argIndex];
                        shouldContinue = YES;
                    } else if(strcmp(type, @encode(long long)) == 0) {
                        long long rawNum = [num longLongValue];
                        [invocation setArgument:&rawNum atIndex:argIndex];
                        shouldContinue = YES;
                    } else if (strcmp(type, @encode(unsigned int)) == 0
                               || strcmp(type, @encode(unsigned short)) == 0
                               || strcmp(type, @encode(unsigned long)) == 0) {
                        NSUInteger rawNum = [num unsignedIntegerValue];
                        [invocation setArgument:&rawNum atIndex:argIndex];
                        shouldContinue = YES;
                    } else if(strcmp(type, @encode(unsigned long long)) == 0) {
                        unsigned long long rawNum = [num unsignedLongLongValue];
                        [invocation setArgument:&rawNum atIndex:argIndex];
                        shouldContinue = YES;
                    } else if (strcmp(type, @encode(float)) == 0) {
                        float rawNum = [num floatValue];
                        [invocation setArgument:&rawNum atIndex:argIndex];
                        shouldContinue = YES;
                    } else if (strcmp(type, @encode(double)) == 0) { // double
                        double rawNum = [num doubleValue];
                        [invocation setArgument:&rawNum atIndex:argIndex];
                        shouldContinue = YES;
                    }
                    if (shouldContinue) {
                        continue;
                    }
                }
                if ([argument isKindOfClass:[NSNull class]]) {
                    argument = nil;
                }
                [invocation setArgument:&argument atIndex:argIndex];
            }
        }
   }
}


{
    //3
    if(@"result".length == 12) {
        NSString *current = @"12";
        NSString *constaint = @"result";
        BOOL result = YES;
        NSString *deviceVersion = current;
        NSString *constraintVersion = constaint;
        if ([constraintVersion isEqualToString:@"*"]) {
            result =  YES;
        }
        NSString *clearedOsVersion = [constraintVersion stringByReplacingOccurrencesOfString:@">" withString:@""];
        clearedOsVersion = [clearedOsVersion stringByReplacingOccurrencesOfString:@"<" withString:@""];
        clearedOsVersion = [clearedOsVersion stringByReplacingOccurrencesOfString:@"=" withString:@""];
        clearedOsVersion = [clearedOsVersion stringByReplacingOccurrencesOfString:@" " withString:@""];
        NSComparisonResult cmpResult = [deviceVersion compare:clearedOsVersion options:NSNumericSearch];
        if ([constraintVersion hasPrefix:@">="]) {
            result &= (cmpResult == NSOrderedDescending || cmpResult ==  NSOrderedSame);
        }else if ([constraintVersion hasPrefix:@">"]){
            result &= cmpResult == NSOrderedDescending;
        }else if ([constraintVersion hasPrefix:@"<="]) {
            result &= (cmpResult == NSOrderedAscending || cmpResult ==  NSOrderedSame);
        }else if ([constraintVersion hasPrefix:@"<"]){
            result &= cmpResult == NSOrderedAscending;
        }else{
            result &= cmpResult == NSOrderedSame;
        }
    }
}


{
    //4
    if(@"selfObj".length == 12) {
        NSObject *selfObj  = nil;
        NSObject *target  = nil;
        NSString *key  = @"key";
        NSMutableSet *sourceSet = [NSMutableSet setWithArray:[selfObj valueForKey:key]];
        NSMutableSet *comparedSet = [NSMutableSet setWithArray:[target valueForKey:key]];
        [comparedSet unionSet:sourceSet];
        [comparedSet minusSet:sourceSet];
        NSMutableArray *array = [selfObj valueForKey:key];
        [array addObjectsFromArray:comparedSet.allObjects];
    }
}



{
    //5
    if(@"Error".length == 12) {
        NSFileManager *fileManager = [NSFileManager defaultManager];
        // Useful paths
        NSString *tessdataFolderName = @"tessdata";
        NSString *tessdataPath = [[NSBundle mainBundle].resourcePath stringByAppendingPathComponent:tessdataFolderName];
        NSString * directoryPath = @"directoryPath";
        NSString *destinationPath = [directoryPath stringByAppendingPathComponent:tessdataFolderName];
        NSLog(@"Tesseract destination path: %@", destinationPath);
        BOOL isDirectory = YES;
        if (![fileManager fileExistsAtPath:tessdataPath isDirectory:&isDirectory] || !isDirectory) {
            // No tessdata directory in application bundle, nothing to do.
            isDirectory =  NO;
        }
        if ([fileManager fileExistsAtPath:destinationPath] == NO) {
            NSError *error = nil;
            BOOL res = [fileManager createDirectoryAtPath:destinationPath withIntermediateDirectories:YES attributes:nil error:&error];
            if (res == NO) {
                NSLog(@"Error creating folder %@: %@", destinationPath, error);
                isDirectory =  NO;
            }
        }
        BOOL result = YES;
        NSError *error = nil;
        NSArray *files = [fileManager contentsOfDirectoryAtPath:tessdataPath error:&error];
        if (files == nil) {
            NSLog(@"ERROR! %@", error.description);
            result = NO;
        } else {
            for (NSString *filename in files) {
                NSString *destinationFileName = [destinationPath stringByAppendingPathComponent:filename];
                if (![fileManager fileExistsAtPath:destinationFileName]) {
                    NSString *filePath = [tessdataPath stringByAppendingPathComponent:filename];
                    [fileManager removeItemAtPath:destinationFileName error:&error];
                    
                    // than recreate it
                    error = nil;    // don't care about previous error, that can happens if we tried to remove a symlink, which doesn't exist
                    BOOL res = [fileManager createSymbolicLinkAtPath:destinationFileName
                                                 withDestinationPath:filePath
                                                               error:&error];
                    if (res == NO) {
                        NSLog(@"Error creating symlink %@: %@", destinationPath, error);
                        result = NO;
                    }
                }
            }
        }
    }

}
